#include "Particle.h"

QDebug operator<< (QDebug d, const Particle &p)
{
    d << "Particle[" <<  p.idx() << "](" << p.position().x() << ", " << p.position().y() << ", " << p.position().z() << ")";
    return d;
}

Particle::Particle(int i, const QVector3D &p, qreal m, const QVector3D &v) :
    m_idx(i), m_p(p), m_v(v), m_m(m),
	m_a(QVector3D(0.0,0.0,0.0)), m_color(QVector3D(1.0,1.0,1.0))
{
}

Particle::Particle() : m_idx(-1), m_m(0.0), m_color(QVector3D(1.0,1.0,1.0))
{

}

Particle::Particle(const Particle& particle)
{
	m_idx      = particle.idx         ();
	m_p        = particle.position    ();
	m_v        = particle.velocity    ();
	m_m        = particle.mass        ();
	m_a        = particle.acceleration();
	m_color    = particle.color       ();

	m_pressure = particle.pressure    ();
	m_density  = particle.density     ();
}

const Particle& Particle::operator=(const Particle& particle)
{
	m_idx      = particle.idx         ();
	m_p        = particle.position    ();
	m_v        = particle.velocity    ();
	m_m        = particle.mass        ();
	m_a        = particle.acceleration();
	m_color    = particle.color       ();

	m_pressure = particle.pressure    ();
	m_density  = particle.density     ();
	return *this;
}

qreal& Particle::mass(void)
{
	return m_m;
}

QVector3D& Particle::velocity(void)
{
	return m_v;
}

QVector3D& Particle::position(void)
{
	return m_p;
}

QVector3D& Particle::acceleration(void)
{
	return m_a;
}

qreal& Particle::pressure  (void)
{
	return m_pressure;
}

qreal&  Particle::density  (void)
{
	return m_density;
}

QVector3D& Particle::color       (void)
{
	return m_color;
}
int        Particle::idx         (void) const
{
	return m_idx;
}
qreal      Particle::mass        (void) const
{
	return m_m;
}
QVector3D  Particle::velocity    (void) const
{
	return m_v;
}
QVector3D  Particle::position    (void) const
{
	return m_p;
}
QVector3D  Particle::acceleration(void) const
{
	return m_a;
}
qreal     Particle:: pressure    (void) const
{
	return m_pressure;
}
qreal      Particle::density     (void) const
{
	return m_density;
}
QVector3D  Particle::color       (void) const
{
	return m_color;
}

void Particle::addAcceleration(const QVector3D &a)
{
	m_a += a;
}

void Particle::resetAcceleration()
{
	m_a = QVector3D();
}

